function e(e, t, i) {
    return t in e ? Object.defineProperty(e, t, {
        value: i,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = i, e;
}

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = {
    addTo: function(t) {
        var i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "";
        Object.assign(this, t);
        var o = i ? i + ".$$actionSheet" : "$$actionSheet";
        t.setData(e({}, o + ".isShown", !1)), Object.assign(t, {
            $$addApp: function(e) {
                var i = this, o = e.currentTarget.dataset, a = o.type, n = o.sid, r = t.data.$$editor.$$actionSheet.index, d = "" + a.charAt(0).toUpperCase() + a.slice(1), s = function() {
                    if ("function" != typeof i["$$editorAdd" + d]) throw new Error("Editor apps/marketings type not supported!");
                    i["$$editorAdd" + d](r), i.$$hideAction();
                };
                "video" === a ? wx.showActionSheet({
                    itemList: [ "从手机相册选择", "从素材库选择" ],
                    success: function(e) {
                        if (0 === e.tapIndex) s(); else {
                            i.$$hideAction();
                            i.$addListener("material:video:choose", function(e) {
                                i.$removeAllListeners("material:video:choose"), i.$$editorAddSection({
                                    type: "video",
                                    data: {
                                        file: {
                                            url: e.source,
                                            fieldid: e.aid,
                                            cover: e.thumburl
                                        },
                                        cover: {
                                            coverurl: e.thumburl
                                        },
                                        content: ""
                                    }
                                }, r);
                            }), i.$route("/pages/editor/material/video/video?sid=" + n);
                        }
                    }
                }) : "payment" === a ? this.$$editorAddSection({
                    type: "application",
                    data: {}
                }, r) : s();
            },
            $$showActionSheet: function(a, n) {
                var r, d = t.data.$$editor, s = d.marketings, c = d.apps, $ = "apps" === n ? c : s, p = "apps" === n ? "应用" : "营销插件";
                t.setData((r = {}, e(r, i + ".actionSheetData", $), e(r, o + ".title", p), e(r, o + ".isShown", !0), 
                e(r, o + ".index", a), r));
            },
            $$hideAction: function() {
                t.setData(e({}, o + ".isShown", !1));
            }
        });
    }
};